<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="{{route('home')}}">Message board</a>

        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
            <ul class="navbar-nav">

                @if(\Illuminate\Support\Facades\Auth::check())
                    <li class="nav-item">
                        <a href="{{route('users.show',Auth::user())}}" class="d-flex justify-content-center">
                            <img
                                src="{{Auth::user()->getAvatar()}}"
                                alt="{{Auth::user()->name}}"
                                width="40"
                                class="rounded border border-2 border-danger"
                            />
                        </a>
                    </li>

                    <li class="nav-item dropdown">
                        <a
                            class="nav-link dropdown-toggle"
                            id="dropdownMenuButton"
                            data-toggle="dropdown"
                            role="button"
                            aria-haspopup="true"
                            aria-expanded="false"
                            href="#"
                        >
                            {{Auth::user()->name}}
                        </a>

                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                            <a class="dropdown-item d-flex justify-content-center" href="{{route('users.show',Auth::user())}}">
                                <small>个人中心</small>
                            </a>
                            <a class="dropdown-item d-flex justify-content-center" href="{{route('users.edit',Auth::user())}}">
                                <small>编辑资料</small>
                            </a>
                            <a class="dropdown-item d-flex justify-content-center" href="{{route('users.index')}}">
                                <small>会员列表</small>
                            </a>

                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item d-flex justify-content-center">
                                <form action="{{route("logout")}}" method="POST">
                                    {{csrf_field()}}
                                    {{method_field('DELETE')}}
                                    <button type="submit" class="btn btn-sm bg-danger">退出登录</button>
                                </form>
                            </a>
                        </div>
                    </li>
                @else
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('login')}}">登录</a>
                    </li>
                @endif

                <li class="nav-item">
                    <a class="nav-link" href="{{route('help')}}">帮助</a>
                </li>
            </ul>
        </div>

    </div>
</nav>
